/*
 * Copyright (C) 2013 Daniel Wasilew <daniel.wasilew@codeminer.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.codeminer.parts.player;

import org.codeminer.parts.devices.Device;
import org.codeminer.parts.library.DefaultIdentifiable;
import org.codeminer.parts.library.Playlist;
import org.codeminer.parts.library.Song;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * User: Daniel Wasilew <daniel.wasilew@codeminer.org>
 * Date: 19.03.13
 * Time: 08:57
 */
public class DefaultPlayer extends DefaultIdentifiable implements Player {

    private String name;
    private final List<Device> devices = new ArrayList<>();
    private Playlist playlist;
    private double currentPosition = -1;
    private Song currentSong;
    private PlayerState playerState = PlayerState.STOPPED;

    public DefaultPlayer() {
    }

    public DefaultPlayer(long oid) {
        super(oid);
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean addDevice(Device device) {
        return this.devices.add(device);
    }

    @Override
    public boolean removeDevice(Device device) {
        return this.devices.remove(device);
    }

    @Override
    public List<Device> getDevices() {
        return Collections.unmodifiableList(this.devices);
    }

    @Override
    public void play() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void pause() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void stop() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void next() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void last() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setPlaylist(Playlist playlist) {
        this.playlist = playlist;
    }

    @Override
    public PlayerInfo getPlayerInfo() {
        return new PlayerInfo(getName(), currentSong, playlist, currentPosition, getDevices(), playerState);
    }
}
